﻿import { createRouter, createWebHistory } from "vue-router";

const routes = [
  {
    path: "/",
    redirect: "/user-permission",
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/pages/login.vue"),
    meta: { title: "用户登录" },
  },
  {
    path: "/notifications",
    name: "Notifications",
    component: () => import("@/pages/通知.vue"),
    meta: { title: "消息通知" },
  },
  /* —————— 监测报警模块 —————— */
  {
    path: "/monitoring-indicators",
    name: "MonitoringIndicators",
    component: () =>
      import("@/pages/监测报警_监测指标统计.vue"),
    meta: { title: "监测指标统计" },
  },
  {
    path: "/data-aggregation",
    name: "DataAggregation",
    component: () =>
      import("@/pages/监测报警_数据汇聚.vue"),
    meta: { title: "数据汇聚" },
  },
  {
    path: "/regional-display",
    name: "RegionalDisplay",
    component: () =>
      import("@/pages/监测预警_区域化展示.vue"),
    meta: { title: "区域化展示" },
  },
  {
    path: "/alarm-event-management",
    name: "AlarmEventManagement",
    component: () =>
      import(
        "@/pages/监测预警_数据汇聚_报警事件管理.vue"
      ),
    meta: { title: "报警事件管理" },
  },
  /* —————— 风险研判模块 —————— */
  {
    path: "/analysis",
    name: "RiskManagementAnalysis",
    //动态引入
    component: () =>
      import("@/pages/风险研判_风险管理与分析.vue"),
    meta: { title: "风险管理与分析" },
  },
  {
    path: "/key-risks",
    name: "RiskManagementKeyRisks",
    component: () =>
      import(
        "@/pages/风险研判_风险管理与分析_全部重点风险提示.vue"
      ),
    meta: { title: "全部重点风险提示" },
  },
  {
    path: "/earlyWarning",
    name: "EarlyWarning",
    component: () =>
      import("@/pages/风险研判_预警信息推送.vue"),
    meta: { title: "预警信息推送" },
  },
  {
    path: "/intelligentRiskAssessment",
    name: "IntelligentRiskAssessment",
    component: () =>
      import("@/pages/风险研判_智能风险评估.vue"),
    meta: { title: "智能风险评估" },
  },
  /* —————— 在线巡查模块 —————— */
  {
    path: "/summary-information",
    name: "SummaryInformation",
    component: () =>
      import("@/pages/在线巡查_企业信息汇总.vue"),
    meta: { title: "企业信息汇总" },
  },
  {
    path: "/patrol",
    name: "Patrol",
    component: () =>
      import("@/pages/在线巡查_巡查功能.vue"),
    meta: { title: "巡查功能" },
  },
  ,
  {
    path: "/inspection-task-details",
    name: "inspection-task-details",
    component: () =>
      import(
        "@/pages/在线巡查_巡查功能_巡查任务详情.vue"
      ),
    meta: { title: "巡查任务详情" },
  },
  {
    path: "/search",
    name: "Search",
    component: () =>
      import("@/pages/在线巡查_检索功能.vue"),
    meta: { title: "检索功能" },
  },
  {
    path: "/screen-display",
    name: "ScreenDisplay",
    component: () =>
      import("@/pages/在线巡查_一屏汇聚展示.vue"),
    meta: { title: "一屏汇聚展示" },
  },
  ,
  {
    path: "/warning-list",
    name: "Warning-list",
    component: () =>
      import(
        "@/pages/在线巡查_一屏汇聚展示_预警信息列表.vue"
      ),
    meta: { title: "预警信息列表" },
  },
  /* —————— 综合分析模块 —————— */
  {
    path: "/equipment",
    name: "Equipment",
    component: () =>
      import("@/pages/综合分析_联网与设备分析.vue"),
    meta: { title: "联网与设备分析" },
  },
  {
    path: "/all-equipment",
    name: "All-equipment",
    component: () =>
      import(
        "@/pages/综合分析_联网与设备分析_全部设备.vue"
      ),
    meta: { title: "全部设备" },
  },
  {
    path: "/application",
    name: "Application",
    component: () =>
      import("@/pages/综合分析_应用情况分析.vue"),
    meta: { title: "应用情况分析" },
  },
  {
    path: "/data-quality",
    name: "DataQuality",
    component: () =>
      import("@/pages/综合分析_数据质量分析.vue"),
    meta: { title: "数据质量分析" },
  },
  {
    path: "/report",
    name: "Report",
    component: () =>
      import("@/pages/综合分析_定期专题报告.vue"),
    meta: { title: "定期专题报告" },
  },
  /* —————— 系统管理模块 —————— */
  {
    path: "/user-permission",
    name: "UserPermission",
    component: () =>
      import("@/pages/系统管理_用户权限管理.vue"),
    meta: { title: "用户权限管理" },
  },
  {
    path: "/system-manage",
    name: "SystemManage",
    component: () =>
      import("@/pages/系统管理_系统配置管理.vue"),
    meta: { title: "系统配置管理" },
  },
  {
    path: "/data-manage",
    name: "DataManage",
    component: () =>
      import("@/pages/系统管理_数据管理.vue"),
    meta: { title: "数据管理" },
  },
  {
    path: "/monitoring",
    name: "Monitoring",
    component: () =>
      import("@/pages/系统管理_系统监控与维护.vue"),
    meta: { title: "系统监控与维护" },
  },

  //   path: '/test',
  //   name: 'test',
  //   component: () => import('@/components/系统管理_数据管理.vue'),
  //   meta: {
  //     title: '智能风险评估',
  //     breadcrumb: ['风险研判', '智能风险评估']
  //   }
  // },
  // 404 页面
  {
    path: "/:pathMatch(.*)*",
    name: "NotFound",
    redirect: "/", // 重定向到首页
    // component: () => import('@/views/error/NotFound.vue')
  },
];

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
});

// 路由守卫 - 设置页面标题和更新菜单状态
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta.title) {
    document.title = `${to.meta.title} - 钢铁企业安全生产智能监管平台`;
  }

  // 可以在这里添加权限验证等逻辑
  next();
});

export default router;
